<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="gly"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<html>
<head>
<meta charset="GB18030">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">

<link rel="stylesheet"
	href="${pageContext.request.contextPath}/static/bootstrap/css/bootstrap.min.css">
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/static/css/font-awesome.min.css">
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/static/css/main.css">

</head>
<body style="margin-top: -50px">
	<div class="panel panel-default" style="margin-top: 0px">
		<div class="panel-heading">
			<h3 class="panel-title">
				<i class="glyphicon glyphicon-th"></i> 事故记录
			</h3>
		</div>
		<div class="panel-body">
			<form class="form-inline" role="form" style="float: left;" method="post" action="${pageContext.request.contextPath}/accident/getByCondition">
				<div class="form-group has-feedback">
					<div class="input-group">
						<div class="input-group-addon">查询依据</div>
						<select class="form-control has-success" name="dr_conditionBy">
							<option value="ac_driver" ${sessionScope.dr_conditionBy=="ac_driver"?"selected":""}>驾驶员姓名</option>
							<option value="ac_carlicense" ${sessionScope.dr_conditionBy=="ac_carlicense"?"selected":""}>车牌号码</option>
						</select>
					</div>
				</div>
				<div class="form-group has-feedback">
					<div class="input-group">
						<div class="input-group-addon">查询条件</div>
						<input class="form-control has-success" type="text"
							placeholder="请输入查询条件，支持模糊查询" name="dr_condition" value="${sessionScope.dr_condition}">
					</div>
				</div>
				<button type="submit" class="btn btn-warning">
					<i class="glyphicon glyphicon-search"></i> 查询
				</button>
			</form>
<form action="${pageContext.request.contextPath}/accident/batchDelete" method="post">
			<button type="submit" class="btn btn-danger"
				style="float: right; margin-left: 10px;" id="sub1">
				<i class=" glyphicon glyphicon-remove"></i> 批量删除
			</button>
			<a class="btn btn-primary" style="float: right; margin-left: 10px;"
				href="${pageContext.request.contextPath}/accident/add"><span
				class="glyphicon glyphicon-plus"></span>增加</a> <br>
			<hr style="clear: both;">
			<div class="table-responsive">
				<table class="table  table-bordered">
					<thead>
						<tr>
							<th width="30">#</th>
							<th width="30"><input type="checkbox" id="selectAll"></th>
							<th>车牌号码</th>
							<th>驾驶员</th>
							<th>事故时间</th>
							<th>事故地点</th>
							<th>事故说明</th>
							<th>我方情况</th>
							<th>对方情况</th>
							<th>处理结果</th>
							<th>我方承担金额</th>
							<th>对方承担金额</th>
							<th>保险承担金额</th>
							<th>违章备注</th>
							<th width="100">操作</th>
						</tr>
					</thead>
					<tbody>
						<gly:forEach items="${pageInfo.list}" var="accident" varStatus="vs">
							<tr>
								<td>${vs.count}</td>
								<td><input type="checkbox" value="${accident.acId}" name="cb"></td>
								<td>${accident.acCarlicense}</td>
								<td>${accident.acDriver}</td>
								<td><fmt:formatDate value="${accident.acTime}"
										pattern="yyyy-MM-dd" /></td>
								<td>${accident.acPlace}</td>
								<td>${accident.acExplain}</td>
								<td>${accident.acWesituation}</td>
								<td>${accident.acHesituation}</td>
								<td>${accident.acResult}</td>
								<td>${accident.acWeamount}</td>
								<td>${accident.acHeamount}</td>
								<td>${accident.acOtheramount}</td>
								<td>${accident.acRemark}</td>
								<td>
									<button type="button" class="btn btn-success btn-xs"
									onclick="window.location.href='${pageContext.request.contextPath}/accident/showInfo?accidentId='+${accident.acId}">
										<i class=" glyphicon glyphicon-list-alt"></i>
									</button>
									<button type="button" class="btn btn-primary btn-xs" onclick="window.location.href='${pageContext.request.contextPath}/accident/update?accidentId='+${accident.acId}">
										<i class=" glyphicon glyphicon-pencil"></i>
									</button>
									<button type="button" class="btn btn-danger btn-xs"
										onclick="window.location.href='${pageContext.request.contextPath}/accident/deleteById?accidentId='+${accident.acId}">
										<i class=" glyphicon glyphicon-remove"></i>
									</button>
								</td>
							</tr>
						</gly:forEach>


					</tbody>

				</table>
			</div>
			</form>
			<div class="row">
				<!--文字信息-->

				<div align="center">
					<ul class="pagination">

						<li><a href="${pageContext.request.contextPath}/accident/getByCondition?dr_pn=1">首页</a></li>

						<!--上一页-->
						<li><gly:if test="${pageInfo.hasPreviousPage}">
								<a
									href="${pageContext.request.contextPath}/accident/getByCondition?dr_pn=${pageInfo.pageNum-1}"
									aria-label="Previous"> <span aria-hidden="true">«</span>
								</a>
							</gly:if></li>

						<!--循环遍历连续显示的页面，若是当前页就高亮显示，并且没有链接-->
						<gly:forEach items="${pageInfo.navigatepageNums}" var="page_num">
							<gly:if test="${page_num == pageInfo.pageNum}">
								<li class="active"><a href="#">${page_num}</a></li>
							</gly:if>
							<gly:if test="${page_num != pageInfo.pageNum}">
								<li><a
									href="${pageContext.request.contextPath}/accident/getByCondition?dr_pn=${page_num}">${page_num}</a></li>
							</gly:if>
						</gly:forEach>

						<!--下一页-->
						<li><gly:if test="${pageInfo.hasNextPage}">
								<a
									href="${pageContext.request.contextPath}/accident/getByCondition?dr_pn=${pageInfo.pageNum+1}"
									aria-label="Next"> <span aria-hidden="true">»</span>
								</a>
							</gly:if></li>

						<li><a
							href="${pageContext.request.contextPath}/accident/getByCondition?dr_pn=${pageInfo.pages}">尾页</a></li>
					</ul>
				</div>
				<div align="center">当前第 ${pageInfo.pageNum} 页.总共
					${pageInfo.pages} 页.一共 ${pageInfo.total} 条记录</div>
			</div>
		</div>

	</div>
	<script
		src="${pageContext.request.contextPath}/static/jquery/jquery-2.1.1.min.js"></script>
	<script
		src="${pageContext.request.contextPath}/static/bootstrap/js/bootstrap.min.js"></script>
	<script
		src="${pageContext.request.contextPath}/static/script/docs.min.js"></script>
	<script type="text/javascript">
	$(function(){
		var deleterows='${deleterows}';
		if (deleterows!="") {
			alert("成功删除"+deleterows+"条记录");
		}
		$("#selectAll").change(function(){
			if($(this).prop('checked')==true){
				$('input[name="cb"]').each(function(){
				$(this).prop('checked',true);
			})
			}else{
				$('input[name="cb"]').each(function(){
					$(this).prop('checked',false);
				})
			}
			
		});
		$("#sub1").click(function(){
			var flag=false;
			$('input[name="cb"]').each(function(){
				if($(this).prop('checked')==true){
					flag=true;
				}
			})
			if (flag==false) {
				alert("请选择删除项目！");
			return false;
			}
			if (confirm("是否删除选中记录?")==false) {
				return false;
			}
		})
		
		
	})
			
		</script>
</body>
</html>